package MapReduce.Demo12_ProductAndOrder.reduceJoin;

import MapReduce.writableBean.ProductAndOrderWritable;
import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.io.WritableComparator;

/**
 * @Author lixinlei
 * @Date 2023/3/23 9:02
 */
public class ProductAndOrderReducerJoinGroupingComparator extends WritableComparator {

    public ProductAndOrderReducerJoinGroupingComparator(){
        super(ProductAndOrderWritable.class,true);
    }

    @Override
    public int compare(WritableComparable a, WritableComparable b) {

        ProductAndOrderWritable aBean = (ProductAndOrderWritable) a;
        ProductAndOrderWritable bBean = (ProductAndOrderWritable) b;

        String aProductId = aBean.getProductId();
        String bProductId = bBean.getProductId();

        return aProductId.compareTo(bProductId);
    }
}
